package com.ikas.ai.server.module.steady.controller;

import com.ikas.ai.handle.JsonResult;
import com.ikas.ai.model.PageQuery;
import com.ikas.ai.server.aop.SpecialPermission;
import com.ikas.ai.server.module.steady.model.dto.StyAlarmDataQueryDto;
import com.ikas.ai.server.module.steady.service.SteadyAlarmDataService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 稳态预警数据管理
 *
 * @author wuyf
 * @since 2023-12-13
 */
@RestController
@RequestMapping("/steadyAlarmData")
public class SteadyAlarmDataController {

    @Resource
    private SteadyAlarmDataService steadyAlarmDataService;

    /**
     * 稳态预警分页查询
     *
     * @param pageQuery 分页信息
     * @return json
     */
    @GetMapping("/page")
    public JsonResult pageStyAlarmData(@Validated StyAlarmDataQueryDto styAlarmDataQueryDto, PageQuery pageQuery) {
        return JsonResult.ok(steadyAlarmDataService.pageStyAlarmData(styAlarmDataQueryDto, pageQuery));
    }

    /**
     * 列表查询
     *
     * @param queryDto 入参对象
     * @return json
     */
    @GetMapping("/list")
    public JsonResult listStyAlarmData(@Validated StyAlarmDataQueryDto queryDto) {
        return JsonResult.ok(steadyAlarmDataService.listStyAlarmData(queryDto));
    }

    /**
     * 确认消缺
     *
     * @param id 主键id
     * @return json of ok
     */
    @GetMapping("/solve/{id}")
    @SpecialPermission(value = {"alarm:solved"})
    public JsonResult solve(@PathVariable("id") Long id) {
        steadyAlarmDataService.solved(id);
        return JsonResult.ok();
    }

    /**
     * 趋势查看
     *
     * @param id
     * @return
     */
    @GetMapping("/trend/{id}")
    public JsonResult trend(@PathVariable("id") Long id) {
        return JsonResult.ok(steadyAlarmDataService.trend(id));
    }

    /**
     * 趋势查看
     *
     * @param id
     * @return
     */
    @GetMapping("/trend/page/{id}")
    public JsonResult trend(@PathVariable("id") Long id, PageQuery pageQuery) {
        return JsonResult.ok(steadyAlarmDataService.trendPage(id, pageQuery));
    }
}
